package cn.tom.service.impl;

import cn.tom.entity.Largefile;
import cn.tom.mapper.LargefileMapper;
import cn.tom.service.LargefileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LargefileServiceImpl implements LargefileService {

    @Autowired
    LargefileMapper largefileMapper;        //注入LargefileMapper接口


    private Logger logger = LoggerFactory.getLogger(toString());

    /**
     * 添加图片
     */
    @Override
    public int add(Largefile largefile) {
        int n = largefileMapper.insert(largefile);
        return n;
    }

    /**
     * 更新图片
     */
    @Override
    public void updateFile(Largefile larFile) {
        int i = largefileMapper.updateById(larFile);
    }

    /**
     * 删除某张图片
     */
    @Override
    public int delByID(String fileId) {
        int i = largefileMapper.deleteById(fileId);
        return i;
    }

    /**
     * 根据ID查询某张图片
     */
    @Override
    public Largefile findById(String id) {
        Largefile fileId = largefileMapper.selectById(id);
        return fileId;
    }

    /**
     * 图片全查询
     */
    @Override
    public List<Largefile> findAll() {
        List<Largefile> largefiles = largefileMapper.selectList(null);
        return largefiles;
    }
}
